using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Threading;
using System.Drawing;
using System.Windows.Forms;
using GoodStuff;
using SampleProcessors;
using Octopus111;
using System.Reflection;
using System.IO;

namespace Octopus111
{
    public static class Housekeeper
    {
        public static void Startup()
        {
            Dictionary<string, object> o = new Dictionary<string,object>();

            GoodObjectBuilder.ReadFile("objects.xml");
            GoodWindow gw = ObjectManager.Get("Main Window") as GoodWindow;
            GoodWindow gw2 = ObjectManager.Get("Second Window") as GoodWindow;
            Thread t1 = new Thread(new ThreadStart(gw.Run));
            Thread t2 = new Thread(new ThreadStart(gw2.Run));
            t1.Start();
            t2.Start();

            //System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);

            //o.Add("Timer", GoodObjectBuilder.Instantiate("SampleProcessors", "GoodTimer"));
            //o.Add("Start Button", GoodObjectBuilder.Instantiate("GoodStuff", "GoodButton"));
            //GoodVariable<string> t = new GoodVariable<string>();
            //((IGoodParameter)t).Set("Start");
            //GoodObjectBuilder.ConnectProperty(o["Start Button"], "Text", t);

            //o.Add("Main Form", GoodObjectBuilder.Instantiate("GoodStuff", "GoodForm"));
            //o.Add("Period", new GoodConvertibleVariable<int>());
 
            //GoodObjectBuilder.SetValue((IGoodParameter)o["Period"], "1000");
            //GoodObjectBuilder.ConnectProperty(o["Timer"], "Period", o["Period"]);
            //GoodObjectBuilder.ConnectEvent(o["Start Button"], "Click", o["Timer"], "Start");
            ////GoodObjectBuilder.AddControl(o["Main Form"], o["Start Button"]);


            //Form f = new Form();
            //FlowLayoutPanel flp = new FlowLayoutPanel();
            //flp.FlowDirection = FlowDirection.TopDown;
            //flp.Margin = new Padding(40);
            //flp.Padding = new Padding(10);
            //flp.Controls.Add(((GoodButton)o["Start Button"]).Control);
            //flp.Controls.Add(new Button());
            //f.Controls.Add(flp);
            //Application.Run(f);
        }

        public static void Cleanup()
        {
        }

   }
}
